/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class CCIChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private float[] typPrice;
/*     */   private float[] cci_parm1;
/*     */   private float[] cciMA_parm2;
/*  22 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  24 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private double p0Y;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  32 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  34 */   public String trend = "";
/*     */   public CCIChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 560 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 561 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 562 */   private Line2D.Double refL1 = new Line2D.Double();
/* 563 */   private Line2D.Double refL2 = new Line2D.Double();
/* 564 */   private Line2D.Double gridY = new Line2D.Double();
/* 565 */   private Line2D.Double gridX = new Line2D.Double();
/* 566 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 567 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 572 */   private Line2D.Double l0 = new Line2D.Double();
/* 573 */   private Line2D.Double l1 = new Line2D.Double();
/* 574 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 576 */   private Line2D.Double uA = new Line2D.Double();
/* 577 */   private Line2D.Double lA = new Line2D.Double();
/* 578 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public CCIChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2)
/*     */   {
/*  39 */     this.sq = paramSymQuotes;
/*  40 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  42 */     this.typPrice = new float[paramSymQuotes.count];
/*  43 */     this.cci_parm1 = new float[paramSymQuotes.count];
/*  44 */     this.cciMA_parm2 = new float[paramSymQuotes.count];
/*     */ 
/*  46 */     this.parm1 = paramInt1;
/*  47 */     this.parm2 = paramInt2;
/*     */ 
/*  49 */     if (this.noOfDays == 150)
/*  50 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  52 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  54 */     setBackground(Color.black);
/*  55 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  57 */     typPrice();
/*     */ 
/*  59 */     if (paramInt1 < paramSymQuotes.count) {
/*  60 */       cci_parm1Finder();
/*     */     }
/*  62 */     if (paramInt1 + paramInt2 < paramSymQuotes.count) {
/*  63 */       cciMA_parm2Finder();
/*     */     }
/*  65 */     findMinMax();
/*  66 */     addMouseMotionListener(this);
/*     */ 
/*  68 */     if (this.cci_parm1[(paramSymQuotes.count - 1)] >= this.cciMA_parm2[(paramSymQuotes.count - 1)])
/*  69 */       this.trend = "Bullish";
/*     */     else {
/*  71 */       this.trend = "Bearish";
/*     */     }
/*  73 */     this.ep = new CCIChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  80 */     this.noOfDays = paramInt;
/*     */ 
/*  82 */     if (paramInt == 150)
/*  83 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  85 */       this.stickWidth = (1.5D * this.xScale);
/*  86 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  93 */     if (this.cci_parm1[paramInt] >= this.cciMA_parm2[paramInt]) {
/*  94 */       return 1;
/*     */     }
/*  96 */     return 0;
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/* 103 */     this.sq = paramSymQuotes;
/* 104 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 106 */     this.typPrice = new float[paramSymQuotes.count];
/* 107 */     this.cci_parm1 = new float[paramSymQuotes.count];
/* 108 */     this.cciMA_parm2 = new float[paramSymQuotes.count];
/*     */ 
/* 110 */     if (this.noOfDays == 150)
/* 111 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 113 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 115 */     typPrice();
/*     */ 
/* 117 */     if (this.parm1 < paramSymQuotes.count) {
/* 118 */       cci_parm1Finder();
/*     */     }
/* 120 */     if (this.parm1 + this.parm2 < paramSymQuotes.count) {
/* 121 */       cciMA_parm2Finder();
/*     */     }
/* 123 */     findMinMax();
/*     */ 
/* 125 */     if (this.cci_parm1[(paramSymQuotes.count - 1)] >= this.cciMA_parm2[(paramSymQuotes.count - 1)])
/* 126 */       this.trend = "Bullish";
/*     */     else {
/* 128 */       this.trend = "Bearish";
/*     */     }
/* 130 */     repaint();
/* 131 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 138 */     Arrays.fill(this.cci_parm1, 0.0F);
/* 139 */     Arrays.fill(this.cciMA_parm2, 0.0F);
/*     */ 
/* 141 */     typPrice();
/*     */ 
/* 143 */     if (this.parm1 < this.sq.count) {
/* 144 */       cci_parm1Finder();
/*     */     }
/* 146 */     if (this.parm1 + this.parm2 < this.sq.count) {
/* 147 */       cciMA_parm2Finder();
/*     */     }
/* 149 */     findMinMax();
/*     */ 
/* 151 */     if (this.cci_parm1[(this.sq.count - 1)] >= this.cciMA_parm2[(this.sq.count - 1)])
/* 152 */       this.trend = "Bullish";
/*     */     else {
/* 154 */       this.trend = "Bearish";
/*     */     }
/* 156 */     repaint();
/* 157 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 165 */     int j = 1;
/* 166 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 168 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 170 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 172 */         j = this.sq.count - 1 - i;
/* 173 */         this.m = ("( " + (String)this.sq.date.get(j) + ", CCI[" + this.parm1 + "]:" + this.df.format(this.cci_parm1[j]) + "  CCI MA[" + this.parm2 + "]:" + this.df.format(this.cciMA_parm2[j]) + " )");
/*     */ 
/* 175 */         this.mX = paramMouseEvent.getX();
/* 176 */         this.mY = paramMouseEvent.getY();
/* 177 */         repaint();
/* 178 */         return;
/*     */       }
/*     */ 
/* 182 */       this.m = "";
/*     */ 
/* 184 */       repaint();
/* 185 */       return;
/*     */     }
/*     */ 
/* 189 */     this.m = "";
/* 190 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 203 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 205 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 206 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 208 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void typPrice()
/*     */   {
/* 215 */     for (int i = 0; i < this.sq.count; i++)
/*     */     {
/* 217 */       this.typPrice[i] = ((((Float)this.sq.high.get(i)).floatValue() + ((Float)this.sq.low.get(i)).floatValue() + ((Float)this.sq.close.get(i)).floatValue()) / 3.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void cci_parm1Finder()
/*     */   {
/* 226 */     for (int i = 0; i < this.parm1; i++) {
/* 227 */       this.cci_parm1[i] = 0.0F;
/*     */     }
/* 229 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 231 */       float f1 = 0.0F;
/* 232 */       float f2 = 0.0F;
/* 233 */       float f3 = 0.0F;
/* 234 */       float f4 = 0.0F;
/*     */ 
/* 236 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 238 */         f2 += this.typPrice[j];
/*     */       }
/*     */ 
/* 242 */       f1 = f2 / this.parm1;
/*     */ 
/* 244 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 246 */         f4 += Math.abs(f1 - this.typPrice[j]);
/*     */       }
/*     */ 
/* 250 */       f3 = f4 / this.parm1;
/*     */ 
/* 252 */       this.cci_parm1[i] = ((this.typPrice[i] - f1) / (0.015F * f3));
/*     */     }
/*     */   }
/*     */ 
/*     */   private void cciMA_parm2Finder()
/*     */   {
/* 261 */     for (int i = 0; i < this.parm1 + this.parm2; i++) {
/* 262 */       this.cciMA_parm2[i] = 0.0F;
/*     */     }
/* 264 */     for (int i = this.parm1 + this.parm2; i < this.sq.count; i++)
/*     */     {
/* 266 */       float f = 0.0F;
/* 267 */       for (int j = i; j > i - this.parm2; j--)
/*     */       {
/* 269 */         f += this.cci_parm1[j];
/*     */       }
/*     */ 
/* 272 */       this.cciMA_parm2[i] = (f / this.parm2);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 280 */     int i = 1;
/* 281 */     this.minVal = this.cci_parm1[(this.sq.count - 1)];
/* 282 */     this.maxVal = this.cci_parm1[(this.sq.count - 1)];
/*     */ 
/* 284 */     for (int j = this.sq.count - 1; j >= this.parm1; j--)
/*     */     {
/* 286 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 289 */       if (this.minVal > this.cci_parm1[j]) {
/* 290 */         this.minVal = this.cci_parm1[j];
/*     */       }
/* 292 */       if (this.maxVal < this.cci_parm1[j]) {
/* 293 */         this.maxVal = this.cci_parm1[j];
/*     */       }
/* 295 */       i += 1;
/*     */     }
/*     */ 
/* 299 */     i = 1;
/* 300 */     for (int j = this.sq.count - 1; j >= this.parm1 + this.parm2; j--)
/*     */     {
/* 302 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 305 */       if (this.minVal > this.cciMA_parm2[j]) {
/* 306 */         this.minVal = this.cciMA_parm2[j];
/*     */       }
/* 308 */       if (this.maxVal < this.cciMA_parm2[j]) {
/* 309 */         this.maxVal = this.cciMA_parm2[j];
/*     */       }
/* 311 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2)
/*     */   {
/* 321 */     this.parm1 = paramInt1;
/* 322 */     this.parm2 = paramInt2;
/*     */ 
/* 324 */     cci_parm1Finder();
/* 325 */     cciMA_parm2Finder();
/* 326 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public Box getCCIBox(boolean paramBoolean)
/*     */   {
/* 333 */     Box localBox = Box.createHorizontalBox();
/* 334 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("CCI");
/*     */ 
/* 336 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 337 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 338 */     this.parm1TF.setFont(this.ssp10);
/* 339 */     this.parm2TF.setFont(this.ssp10);
/* 340 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 341 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 343 */     JLabel localJLabel1 = new JLabel("CCI[");
/* 344 */     JLabel localJLabel2 = new JLabel("] ,  CCI MA[");
/* 345 */     JLabel localJLabel3 = new JLabel("]     ");
/*     */ 
/* 347 */     localJLabel1.setFont(this.ssp10);
/* 348 */     localJLabel2.setFont(this.ssp10);
/* 349 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 351 */     localBox.add(localJLabel1);
/* 352 */     localBox.add(this.parm1TF);
/* 353 */     localBox.add(localJLabel2);
/* 354 */     localBox.add(this.parm2TF);
/* 355 */     localBox.add(localJLabel3);
/*     */ 
/* 357 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 359 */     if (paramBoolean) {
/* 360 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 362 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 369 */     JFrame localJFrame = new JFrame();
/* 370 */     this.chgParmDialog = new JDialog(localJFrame, "Change CCI Parameters", true);
/* 371 */     Box localBox1 = Box.createVerticalBox();
/* 372 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 374 */     this.chgParmOk = new JButton("OK");
/* 375 */     this.chgParmOk.setFont(this.ssp10);
/* 376 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 377 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 379 */     this.chgParmCancel = new JButton("Cancel");
/* 380 */     this.chgParmCancel.setFont(this.ssp10);
/* 381 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 382 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 384 */     this.defaultParms = new JButton("Default");
/* 385 */     this.defaultParms.setFont(this.ssp10);
/* 386 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 387 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 388 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 390 */     localBox2.add(Box.createHorizontalGlue());
/* 391 */     localBox2.add(this.chgParmOk);
/* 392 */     localBox2.add(Box.createHorizontalStrut(5));
/* 393 */     localBox2.add(this.chgParmCancel);
/* 394 */     localBox2.add(Box.createHorizontalStrut(5));
/* 395 */     localBox2.add(this.defaultParms);
/* 396 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 398 */     localBox1.add(getCCIBox(true));
/* 399 */     localBox1.add(localBox2);
/*     */ 
/* 401 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 402 */     this.chgParmDialog.setSize(250, 100);
/* 403 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 404 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 411 */     int i = this.parm1;
/* 412 */     int j = this.parm2;
/*     */     try
/*     */     {
/* 416 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 417 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 423 */       JOptionPane.showMessageDialog(null, "Error in CCI parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 426 */       this.parm1TF.setText("" + this.parm1);
/* 427 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 429 */       return false;
/*     */     }
/*     */ 
/* 433 */     if ((i > 200) || (j > 200))
/*     */     {
/* 435 */       JOptionPane.showMessageDialog(null, "Error in CCI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 438 */       this.parm1TF.setText("" + this.parm1);
/* 439 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 441 */       return false;
/*     */     }
/*     */ 
/* 445 */     if ((i < 2) || (j < 2))
/*     */     {
/* 447 */       JOptionPane.showMessageDialog(null, "Error in CCI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 450 */       this.parm1TF.setText("" + this.parm1);
/* 451 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 453 */       return false;
/*     */     }
/*     */ 
/* 457 */     this.parm1 = i;
/* 458 */     this.parm2 = j;
/*     */ 
/* 460 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 467 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 469 */       if (!validateParm()) {
/* 470 */         return;
/*     */       }
/* 472 */       redrawChart();
/* 473 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 477 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 479 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 483 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 485 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 494 */     this.parm1TF.setText("15");
/* 495 */     this.parm2TF.setText("7");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 502 */     if (paramBoolean)
/* 503 */       this.yScale += 0.2F;
/* 504 */     else if (this.yScale >= 1.2F) {
/* 505 */       this.yScale -= 0.2F;
/*     */     }
/* 507 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 514 */     if (paramBoolean)
/* 515 */       this.xScale += 0.2F;
/* 516 */     else if (this.xScale >= 1.2F) {
/* 517 */       this.xScale -= 0.2F;
/*     */     }
/* 519 */     if (this.noOfDays == 150)
/* 520 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 522 */       this.stickWidth = (1.5D * this.xScale);
/* 523 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 530 */     this.yScale = 1.0F;
/* 531 */     this.xScale = 1.0F;
/* 532 */     if (this.noOfDays == 150)
/* 533 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 535 */       this.stickWidth = (1.5D * this.xScale);
/* 536 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 543 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 550 */     clear(paramGraphics);
/* 551 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 552 */     drawChart(localGraphics2D);
/* 553 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 583 */     this.refY = 10.0D;
/* 584 */     this.refX = 50.0D;
/* 585 */     setFont(this.ssp10);
/* 586 */     String str = "Commodity Channel Index";
/* 587 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 588 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 590 */     str = "CCI[" + this.parm1 + "]";
/* 591 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 592 */     paramGraphics2D.drawString(str, 185, 10);
/*     */ 
/* 594 */     str = "CCI MA[" + this.parm2 + "]";
/* 595 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 596 */     paramGraphics2D.drawString(str, 230, 10);
/*     */ 
/* 599 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 600 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 601 */     paramGraphics2D.setPaint(Color.white);
/* 602 */     paramGraphics2D.draw(this.refL1);
/* 603 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 605 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 607 */       this.refX += 50.0F * this.xScale;
/* 608 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 609 */       paramGraphics2D.setPaint(Color.darkGray);
/* 610 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 614 */     for (i = 0; i < 11; i++)
/*     */     {
/* 616 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 617 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 618 */       paramGraphics2D.setPaint(Color.lightGray);
/* 619 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 620 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 622 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 623 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 624 */       paramGraphics2D.setPaint(Color.white);
/* 625 */       paramGraphics2D.draw(this.yrefL1);
/* 626 */       paramGraphics2D.draw(this.yrefL2);
/* 627 */       paramGraphics2D.setPaint(Color.darkGray);
/* 628 */       paramGraphics2D.draw(this.gridX);
/* 629 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 633 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 634 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 635 */     this.dateRef = (this.sq.count - 1);
/* 636 */     this.daysRef = 1;
/*     */ 
/* 639 */     this.p0Y = (this.yScale * 100.0F + 10.0F - (0.0F - this.minVal) * this.yfactor);
/* 640 */     this.l0.setLine(50.0D, this.p0Y, 750.0F * this.xScale + 50.0F, this.p0Y);
/* 641 */     paramGraphics2D.setPaint(Color.white);
/* 642 */     paramGraphics2D.draw(this.l0);
/*     */ 
/* 644 */     this.p0Y = (this.yScale * 100.0F + 10.0F - (-100.0F - this.minVal) * this.yfactor);
/* 645 */     this.l0.setLine(50.0D, this.p0Y, 750.0F * this.xScale + 50.0F, this.p0Y);
/* 646 */     paramGraphics2D.setPaint(new Color(120, 120, 0));
/* 647 */     paramGraphics2D.draw(this.l0);
/*     */ 
/* 649 */     this.p0Y = (this.yScale * 100.0F + 10.0F - (100.0F - this.minVal) * this.yfactor);
/* 650 */     this.l0.setLine(50.0D, this.p0Y, 750.0F * this.xScale + 50.0F, this.p0Y);
/* 651 */     paramGraphics2D.setPaint(new Color(120, 120, 0));
/* 652 */     paramGraphics2D.draw(this.l0);
/*     */ 
/* 654 */     for (i = this.sq.count - 1; i > this.parm1; i--)
/*     */     {
/* 656 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 658 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 661 */       if (i > this.parm1 + this.parm2)
/*     */       {
/* 663 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.cciMA_parm2[i] - this.minVal) * this.yfactor);
/* 664 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.cciMA_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 666 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 667 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 668 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 672 */       if (i > this.parm1)
/*     */       {
/* 674 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.cci_parm1[i] - this.minVal) * this.yfactor);
/* 675 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.cci_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 677 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 678 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 679 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 683 */       if ((i > this.parm1 + this.parm2) && (this.cci_parm1[i] - this.cciMA_parm2[i] >= 0.0F) && (this.cci_parm1[(i - 1)] - this.cciMA_parm2[(i - 1)] < 0.0F))
/*     */       {
/* 685 */         this.x1 = this.startPointX;
/* 686 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 687 */         this.y1 = this.p1Y;
/* 688 */         this.y2 = this.p2Y;
/* 689 */         this.u1 = this.x1;
/* 690 */         this.u2 = this.x2;
/* 691 */         this.v1 = this.p11Y;
/* 692 */         this.v2 = this.p22Y;
/*     */ 
/* 694 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 695 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 697 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 698 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 700 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 701 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 703 */         paramGraphics2D.setPaint(Color.green);
/* 704 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 705 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 706 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 707 */         paramGraphics2D.draw(this.uA);
/* 708 */         paramGraphics2D.draw(this.lA);
/* 709 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 713 */       if ((i > this.parm1 + this.parm2) && (this.cci_parm1[i] - this.cciMA_parm2[i] < 0.0F) && (this.cci_parm1[(i - 1)] - this.cciMA_parm2[(i - 1)] > 0.0F))
/*     */       {
/* 715 */         this.x1 = this.startPointX;
/* 716 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 717 */         this.y1 = this.p1Y;
/* 718 */         this.y2 = this.p2Y;
/* 719 */         this.u1 = this.x1;
/* 720 */         this.u2 = this.x2;
/* 721 */         this.v1 = this.p11Y;
/* 722 */         this.v2 = this.p22Y;
/*     */ 
/* 724 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 725 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 727 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 728 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 730 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 731 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 733 */         paramGraphics2D.setPaint(Color.red);
/* 734 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 735 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 736 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 737 */         paramGraphics2D.draw(this.uA);
/* 738 */         paramGraphics2D.draw(this.lA);
/* 739 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 743 */       if (this.dateRef == i)
/*     */       {
/* 745 */         paramGraphics2D.setFont(this.ssp9);
/* 746 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 747 */         if (this.cci_parm1[i] >= this.cciMA_parm2[i])
/* 748 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 750 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 752 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 753 */         if (this.noOfDays == 150)
/* 754 */           this.dateRef -= 10;
/*     */         else
/* 756 */           this.dateRef -= 20;
/* 757 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 761 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 762 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 831 */     FileDownloader localFileDownloader = new FileDownloader();
/* 832 */     localFileDownloader.downloadFiles();
/* 833 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 835 */     CCIChart localCCIChart = new CCIChart(localSymQuotes, 15, 7);
/*     */ 
/* 837 */     JFrame localJFrame = new JFrame("Test");
/* 838 */     localJFrame.setDefaultCloseOperation(3);
/* 839 */     localJFrame.getContentPane().add(localCCIChart);
/* 840 */     localJFrame.pack();
/* 841 */     localJFrame.setSize(850, 175);
/* 842 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel cciL;
/*     */     private JLabel cciMaL;
/*     */     private JLabel l1;
/*     */     private JLabel l2;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 774 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 775 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 779 */       this.title = new JLabel("CCI");
/* 780 */       this.cciL = new JLabel("CCI[" + CCIChart.this.parm1 + "]: " + CCIChart.this.df.format(CCIChart.this.cci_parm1[(CCIChart.this.sq.count - 1)]));
/* 781 */       this.cciMaL = new JLabel("CCI MA[" + CCIChart.this.parm2 + "]: " + CCIChart.this.df.format(CCIChart.this.cciMA_parm2[(CCIChart.this.sq.count - 1)]));
/* 782 */       this.l1 = new JLabel("Overbought:CCI > 100");
/* 783 */       this.l2 = new JLabel("Oversold:CCI < -100");
/*     */ 
/* 785 */       this.trendL = new JLabel("Trend: " + CCIChart.this.trend);
/* 786 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/cci.htm", "Help on CCI");
/*     */ 
/* 788 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 790 */       this.cciL.setFont(this.valuesF);
/* 791 */       this.cciMaL.setFont(this.valuesF);
/* 792 */       this.trendL.setFont(this.valuesF);
/* 793 */       this.l1.setFont(this.valuesF);
/* 794 */       this.l2.setFont(this.valuesF);
/*     */ 
/* 796 */       this.buttonsPanel.add(this.chb);
/* 797 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 798 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 800 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 802 */       add(this.title);
/* 803 */       add(this.cciL);
/* 804 */       add(this.cciMaL);
/* 805 */       add(new JLabel(" "));
/* 806 */       add(this.trendL);
/* 807 */       add(this.l1);
/* 808 */       add(this.l2);
/* 809 */       add(this.buttonsPanel);
/* 810 */       add(Box.createVerticalGlue());
/*     */ 
/* 812 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 819 */       this.cciL.setText("CCI[" + CCIChart.this.parm1 + "]: " + CCIChart.this.df.format(CCIChart.this.cci_parm1[(CCIChart.this.sq.count - 1)]));
/* 820 */       this.cciMaL.setText("CCI MA[" + CCIChart.this.parm2 + "]: " + CCIChart.this.df.format(CCIChart.this.cciMA_parm2[(CCIChart.this.sq.count - 1)]));
/* 821 */       this.trendL.setText("Trend: " + CCIChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     CCIChart
 * JD-Core Version:    0.6.0
 */